package com.xukai.springboot.controller.sys;

import com.xukai.springboot.entity.request.sys.DelAuthorityRequest;
import com.xukai.springboot.entity.request.sys.StopAuthorityRequest;
import com.xukai.springboot.entity.response.PageResult;
import com.xukai.springboot.entity.response.ResponseBase;
import com.xukai.springboot.entity.sys.t_sys_authority;
import com.xukai.springboot.entity.sys.t_sys_role_authority;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

@Api(basePath = "api/sys/authority", description = "权限管理")
@RestController
@RequestMapping("api/sys/authority/*")
public class AuthorityController {


    /**
     * 日志
     */
    private final Logger logger = LoggerFactory.getLogger(AuthorityController.class);

    /**
     * 获取权限列表
     */
    @ApiOperation(value = "获取权限列表", notes = "获取权限列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "StartIndex", value = "检索起始数据", required = true, dataType = "int", example = "0",defaultValue ="0" , paramType = "query"),
            @ApiImplicitParam(name = "PageSize", value = "分页大小", required = true, dataType = "int", example = "0",defaultValue ="0" , paramType = "query"),
            @ApiImplicitParam(name = "AuthorityName", value = "权限名称", required = true, dataType = "string", paramType = "query")
    })
    @GetMapping("GetAuthorityList")
    public ResponseBase<PageResult<t_sys_authority>> GetAuthorityList(@RequestParam int StartIndex, @RequestParam int PageSize, @RequestParam String AuthorityName) {
        ResponseBase<PageResult<t_sys_authority>> result = new ResponseBase<>();
        try {
        } catch (Exception e) {
            logger.error("获取权限列表", e);
            result.setStatue(0);
        }
        return result;
    }


    /**
     * 获取权限详细信息
     */
    @ApiOperation(value = "获取权限详细信息", notes = "获取权限详细信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "AuthorityID", value = "权限ID", required = true, dataType = "int", example = "0",defaultValue ="0" , paramType = "query")
    })
    @GetMapping("GetAuthority")
    public ResponseBase<PageResult<t_sys_authority>> GetAuthority(@RequestParam int AuthorityID) {
        ResponseBase<PageResult<t_sys_authority>> result = new ResponseBase<>();
        try {
        } catch (Exception e) {
            logger.error("获取权限详细信息", e);
            result.setStatue(0);
        }
        return result;
    }

    /**
     * 新建权限列表
     */
    @ApiOperation(value = "新建权限列表", notes = "新建权限列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Param", value = "权限数据", required = true, dataType = "t_sys_authority", paramType = "body")
    })
    @PostMapping("CreateAuthority")
    public ResponseBase<t_sys_authority> CreateAuthority(@RequestBody t_sys_authority Param) {
        ResponseBase<t_sys_authority> result = new ResponseBase<>();
        try {

        } catch (Exception e) {
            logger.error("新建权限列表", e);
            result.setStatue(0);
        }
        return result;
    }

    /**
     * 修改权限列表
     */
    @ApiOperation(value = "修改权限列表", notes = "修改权限列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Param", value = "权限数据", required = true, dataType = "t_sys_authority", paramType = "body")
    })
    @PostMapping("EditAuthority")
    public ResponseBase EditAuthority(@RequestBody t_sys_authority Param) {
        ResponseBase result = new ResponseBase();
        try {

        } catch (Exception e) {
            logger.error("修改权限列表", e);
            result.setStatue(0);
        }
        return result;
    }

    /**
     * 删除权限
     */
    @ApiOperation(value = "删除权限", notes = "删除权限")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Param", value = "删除权限参数", required = true, dataType = "DelAuthorityRequest", paramType = "body")
    })
    @PostMapping("DelAuthority")
    public ResponseBase DelAuthority(@RequestBody DelAuthorityRequest Param) {
        ResponseBase result = new ResponseBase();
        try {

        } catch (Exception e) {
            logger.error("删除权限", e);
            result.setStatue(0);
        }
        return result;
    }

    /**
     * 停用权限
     */
    @ApiOperation(value = "停用权限", notes = "停用权限")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Param", value = "停用权限参数", required = true, dataType = "StopAuthorityRequest", paramType = "body")
    })
    @PostMapping("StopAuthorityRequest")
    public ResponseBase DelAuthority(@RequestBody StopAuthorityRequest Param) {
        ResponseBase result = new ResponseBase();
        try {

        } catch (Exception e) {
            logger.error("停用权限", e);
            result.setStatue(0);
        }
        return result;
    }

    /**
     * 获取权限角色
     */
    public ResponseBase<PageResult<t_sys_role_authority>> GetAuthorityRole(@RequestParam int AuthorityID) {
        ResponseBase result = new ResponseBase();
        try {

        } catch (Exception e) {
            logger.error("获取权限角色", e);
            result.setStatue(0);
        }
        return result;
    }

}
